#include "StdAfx.h"
#include "FunctionDriverCircle.h"
#include "RegFunctionDriverHelper.h"
#include "../CircleBuilder.h"
CFunctionDriverCircle::CFunctionDriverCircle()
{
}
CFunctionDriverCircle::~CFunctionDriverCircle()
{
}

const Standard_GUID& CFunctionDriverCircle::GetID() {
	static Standard_GUID anID(CIRCLE_CP_GUID);
	return anID;
}


void CFunctionDriverCircle::Validate(TFunction_Logbook& log) const
{
	// We validate the object label ( Label() ), all the arguments and the results of the object:
	log.SetValid(Label(), Standard_True);
}

Standard_Boolean CFunctionDriverCircle::MustExecute(const TFunction_Logbook& log) const
{

	if (log.IsModified(Label())) 
		return Standard_True; 

	if(CCircleInfo::IsModified(Label(), log))
		return Standard_True;

	return Standard_False;
}

Standard_Integer CFunctionDriverCircle::Execute(TFunction_Logbook& log) const
{
	CCircleInfo info;
	if(!info.GetFromLabel(Label()))
		return 1;

	TopoDS_Shape shape;
	CCircleBuilder builder;
	if(!builder.Build(&info, shape))
		return 1;

	// Build a TNaming_NamedShape using built box
	TNaming_Builder B(Label());
	B.Generated(shape);

	return 0;
}


//////////////////////////////////////////////////////////////////////////
IMPLEMENT_FUNCTIONDRIVER_HANDLE(CFunctionDriverCircle)

REGISTER_FUNCTIONDRIVER(CFunctionDriverCircle)